package cn.kgc.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 课工场
 * @date 2024/5/5
 * @description
 */
@Controller
@RequestMapping("springmvc")
public class SpringmvcController {

    //  添加数据     /mvc/springmvc/add    转发
    @RequestMapping("add")
    public ModelAndView  addData(){
        // 模型和视图的封装对象    数据和视图名
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("hello");
        modelAndView.addObject("info","数据添加成功");
        return modelAndView;
    }

    // 删除数据  /mvc/springmvc/delete
    @RequestMapping("delete")
    public ModelAndView  deleteData(){
        // 模型和视图的封装对象    数据和视图名
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("hello");
        modelAndView.addObject("info","数据删除成功");
        return modelAndView;
    }

}
